package com.example.wuyou.juc;

public class LPThread implements Runnable{
    private static final Object lock = new Object();
    static int lp = 100;
    @Override
    public void run() {
        while (true){
            synchronized (lock) {
                if (lp <= 10) {
                    System.out.println("窗口" + Thread.currentThread().getName() + "发现不能再发了");
                    break;
                }
                lp--;
                System.out.println("窗口" + Thread.currentThread().getName() + "发送了一个礼品，剩余" + lp + "个礼品");
            }
        }
    }
}
